package com.njtoyo.taxi.admin.rest.controller.data;

import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.AllowanceStatsPresenter;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.OverviewAllowanceChartPresenter;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.OverviewRecommendChartPresenter;
import com.njtoyo.taxi.admin.rest.wrapper.data.allowance.AllowanceChartWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.data.allowance.AllowanceWrapper;
import com.njtoyo.taxi.admin.service.data.AllowanceService;
import com.taxi.entity.common.RestResult;
import com.njtoyo.taxi.entity.backend.AdminUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;

@RequestMapping("/data/allowance")
@Api(value = "补贴统计-缓存数据", tags = "补贴统计")
@RestController
public class AllowanceController {

    @Qualifier("allowanceServiceCacheImpl")
    @Autowired
    private AllowanceService allowanceService;

    @GetMapping("")
    @ApiOperation(value = "补贴统计", notes = "权限：allowance")
    @PermissionScope(names = {"allowance"})
    public RestResult<AllowanceStatsPresenter> main(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceService.main(adminUser, wrapper);
    }

    @GetMapping("/total/chart")
    @ApiOperation(value = "补贴总额-单均补贴趋势图", notes = "权限：allowance")
    @PermissionScope(names = {"allowance"})
    public RestResult<List<OverviewAllowanceChartPresenter>> totalChart(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceService.totalChart(adminUser, wrapper);
    }

    @GetMapping("/recommend/chart")
    @ApiOperation(value = "推广人数趋势图", notes = "权限：allowance")
    @PermissionScope(names = {"allowance"})
    public RestResult<List<OverviewRecommendChartPresenter>> recommendChart(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceService.recommendChart(adminUser, wrapper);
    }

}
